//Lake Counting S:https://www.luogu.com.cn/problem/P1596

#include <iostream>
#include <queue>
using namespace std;

const int N = 110;

char d[N][N];
bool f[N][N];
int n,m;

int dx[] = {0,0,1,-1,-1,1,-1,1};
int dy[] = {1,-1,0,0,-1,1,1,-1};

void bfs(int i,int j)
{
	queue<pair<int,int>> q;
	q.push({i,j});
	while(q.size())
	{
		pair<int,int> p = q.front();
		q.pop();
		int x = p.first;
		int y = p.second;
		for(int i = 0; i < 8; i++)
		{
			int a = x +dx[i];
			int b = y +dy[i];
			if(a < 0 || b < 0 || a >= n || b >= m || f[a][b] == true)continue;
			if(d[a][b] == '.')
			{
				f[a][b] = true;
				continue;
			}
			f[a][b] = true;
			q.push({a,b});
		}
	}
}

int main()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> d[i][j];
		}
	}
	
	int ret = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(f[i][j] == true)continue;
			else if(d[i][j] == '.')f[i][j] = true;
			else 
			{
				bfs(i,j);
				ret++;
			}
		}
	}
	cout << ret;
	return 0;
}
